package com.thti.mecool.client.adapter;

import java.util.List;

import com.thti.mecool.client.activity.R;
import com.thti.mecool.client.model.po.MobileMessages;
import com.thti.mecool.client.model.po.MsgItem;
import com.thti.mecool.client.util.TimeUtil;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class UserCenterMsgItemAdapter extends BaseAdapter {
	Context mContext;
	List<MobileMessages> mList;
	
	public UserCenterMsgItemAdapter(Context mContext, List<MobileMessages> mList) {
		super();
		this.mContext = mContext;
		this.mList = mList;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view =((Activity) mContext).getLayoutInflater().inflate(R.layout.mecool_usercenter_msg_list_item,null);
		ImageView alertImage;
		TextView title,content,sendTime;
		try {
			view.setTag(position);
			alertImage=(ImageView)view.findViewById(R.id.mecool_usercenter_msg_list_item_alert);
			title=(TextView)view.findViewById(R.id.mecool_usercenter_msg_list_item_title);
			title.setText(mList.get(position).getHead());
			content=(TextView)view.findViewById(R.id.mecool_usercenter_msg_list_item_content);
			content.setText(mList.get(position).getBody());
			sendTime=(TextView)view.findViewById(R.id.mecool_usercenter_msg_list_item_sendtime);
			sendTime.setText(TimeUtil.getDateConvert(mList.get(position).getCreatedOn(),11));
		} catch (Exception e) { 
			// TODO: handle exception
		}
		return view;
	}
	
	//	LinearLayout linear=new LinearLayout(mContext);
	//	linear.setBackgroundResource(R.drawable.mecool_listview_selector);
	//	linear.setOrientation(1);
	//	TextView tv1=new TextView(mContext);
	//	tv1.setText(mList.get(position).getHead());
	//	linear.addView(tv1);
	//	LinearLayout layout=new LinearLayout(mContext);
	//	layout.setOrientation(0);
	//	TextView tv2=new TextView(mContext);
	//	tv2.setText(mList.get(position).getBody());
	//	layout.addView(tv2);
	//	TextView tv3=new TextView(mContext);
	//	tv3.setText(mList.get(position).getCreatedOn());
	//	layout.addView(tv3);
	//	linear.addView(layout);
	//	return linear;
	//}
}
